/**
 * 实现一个场景
 * 如果type === 'add',执行addHandler()
 * 如果type === 'remove',执行removeHandler()
 * 如果type === 'update', 执行updateHandler()
 */



class Calculator {
  static addHandler() {
    console.log('add');
  }
  static removeHandler() {
    console.log('remove');
  }
  static updateHandler() {
    console.log('update');
  }
}

enum Type {
  add = 'addHandler',
  remove = 'removeHandler',
  update = 'addHandler',
}

function oldFunction(type: Type) {
  if (type === Type.add) {
    Calculator.addHandler()
  } else if (type === Type.remove) {
    Calculator.removeHandler()
  } else if (type === Type.update) {
    Calculator.updateHandler()
  }
}

function newFunction(type: Type) {
  Calculator[type]()
}

newFunction(Type.add)